<template>
  <tr>
    <td><input type="checkbox" /></td>
    <td>{{ name }}</td>
    <td>{{ price }}</td>
    <td>
      <button @click.prevent="cutFn">-</button>
      {{ num }}
      <button @click.prevent="addFn">+</button>
    </td>
    <td>{{ num * price }}</td>
    <td><button @click.prevent="delFn(cutNum)">删除</button></td>
  </tr>
</template>

<script>
export default {
  props: ["name", "price", "num", "cutNum"],
  methods: {
    delFn(index) {
      console.log(index);
    },
    addFn() {
      this.num += 1;
    },
    cutFn() {
      this.num > 0 ? (this.num -= 1) : (this.num = 0);
    },
  },
};
</script>

<style>
</style>